package io;

import java.io.*;

/**
 * 缓冲流：是一对高级流，作用是加快读写频率
 */
public class CopyDemo3Buffer {
    public static void main(String[] args) throws IOException {
        FileInputStream file = new FileInputStream("image.png");///1
        BufferedInputStream buffer = new BufferedInputStream(file);
        FileOutputStream file1 = new FileOutputStream("image.cd.png");
        BufferedOutputStream buffer1 = new BufferedOutputStream(file1);
        long start = System.currentTimeMillis();
        int d;
        while ((d = buffer.read()) != -1) {
            buffer1.write(d);
        }
        long end = System.currentTimeMillis();
        System.out.println("运行时间是：" + (end - start));
        buffer.close();
        buffer1.close();
    }
}
